package com.wangyk.springsecurity.config;

import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.stereotype.Controller;

/**
 * WebSecurityConfigurerAdapter：适配器类，Web应用的适配器
 * */
@Controller
public class BrowserSecurityConfig extends WebSecurityConfigurerAdapter
{
    /**
     * 使用表单登录
     * */
    @Override
    protected void configure(HttpSecurity http)
        throws Exception
    {
        http.httpBasic()//弹出对话框的形式
        //http.formLogin()//表单登录
            .and()
            .authorizeRequests()//对请求授权
            .anyRequest()//对所有请求授权
            .authenticated();//都需要身份认证
    }
}
